package myky.com.doctorapp.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import myky.com.doctorapp.R
import myky.com.doctorapp.entity.DepatmentAndAreaEntity

class DoctorLisProvinceAdapter(mAreaPronviceList: MutableList<DepatmentAndAreaEntity.DataEntity.AreaEntity>) : BaseQuickAdapter<DepatmentAndAreaEntity.DataEntity.AreaEntity, BaseViewHolder>(R.layout.item_doc_list_area, mAreaPronviceList) {

    var selectedProvince: String = ""


    fun setProvince(province: String) {
        this.selectedProvince = province
    }


    override fun convert(holder: BaseViewHolder, item: DepatmentAndAreaEntity.DataEntity.AreaEntity) {

        val province = item.province

        holder.setText(R.id.pop_parent_tv, province)

        if (province.equals(selectedProvince)) {
            holder.setBackgroundRes(R.id.doc_province_lisrview_item, R.color.white)
        } else {
            holder.setBackgroundRes(R.id.doc_province_lisrview_item, R.color.gray_eeeeee)
        }

        holder.addOnClickListener(R.id.doc_province_lisrview_item)
    }
}